﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StoreReport.aspx.cs" Inherits="H2.NET.Web.Pages.SMD.StoreReport" %>

<style>
    .flowpage1
    {
        margin-top: 4px;
    }
    .report
    {
        text-align: center;
    }
    .report input
    {
        width: 30px;
        border: 0;
        border-bottom: 1px solid #a9a9a9;
        text-align: center;
    }
</style>
<script type="text/javascript">
    $(function () {
        $(".report input").keyup(function () {
            var id = $(this).attr("id");
            var oID;
            var total;
            var complete;
            var isRenew = false;
            var isDdcn = false;
            var gap;
            var east;
            var south;
            var west;
            var north;
            var type = id.split("_")[0];
            if (type == "ddcn") {
                isDdcn = true;
            }
            if (id.indexOf("_r") > -1) {
                isRenew = true;
                oID = id.substring(0, id.indexOf("_r"));
                total = oID + "_all";
                gap = oID.replace("target", "gap");
            } else {
                oID = id + "_r";
                total = id + "_all";
                gap = id.replace("target", "gap");
            }
            complete = total.replace("target", "complete");
            $("#" + total).val(parseInt(isnull($("#" + id).val())) + parseInt(isnull($("#" + oID).val())));
            $("#" + gap).val(parseInt(isnull($("#" + total).val()) - parseInt(isnull($("#" + complete).val()))));
            if (isRenew) {

                if (isDdcn) {
                    east = parseInt(isnull($("#ddcn_East_target_r").val()));
                    south = parseInt(isnull($("#ddcn_South_target_r").val()));
                    west = parseInt(isnull($("#ddcn_West_target_r").val()));
                    north = parseInt(isnull($("#ddcn_North_target_r").val()));
                    $("#ddcn_All_target_r").val(east + south + west + north);
                } else {
                    east = parseInt(isnull($("#dcss_East_target_r").val()));
                    south = parseInt(isnull($("#dcss_South_target_r").val()));
                    west = parseInt(isnull($("#dcss_West_target_r").val()));
                    north = parseInt(isnull($("#dcss_North_target_r").val()));
                    $("#dcss_All_target_r").val(east + south + west + north);
                }
            } else {
                if (isDdcn) {
                    east = parseInt(isnull($("#ddcn_East_target").val()));
                    south = parseInt(isnull($("#ddcn_South_target").val()));
                    west = parseInt(isnull($("#ddcn_West_target").val()));
                    north = parseInt(isnull($("#ddcn_North_target").val()));
                    $("#ddcn_All_target").val(east + south + west + north);
                } else {
                    east = parseInt(isnull($("#dcss_East_target").val()));
                    south = parseInt(isnull($("#dcss_South_target").val()));
                    west = parseInt(isnull($("#dcss_West_target").val()));
                    north = parseInt(isnull($("#dcss_North_target").val()));
                    $("#dcss_All_target").val(east + south + west + north);
                }
            }

            if (isDdcn) {
                $("#ddcn_All_target_all").val(parseInt(isnull($("#ddcn_All_target").val())) + parseInt(isnull($("#ddcn_All_target_r").val())));
            } else {
                $("#dcss_All_target_all").val(parseInt(isnull($("#dcss_All_target").val())) + parseInt(isnull($("#dcss_All_target_r").val())));
            }

            if (isDdcn) {
                $("#ddcn_All_gap").val(parseInt(isnull($("#ddcn_All_target_all").val())) - parseInt(isnull($("#ddcn_All_complete_all").val())));
            } else {
                $("#dcss_All_gap").val(parseInt(isnull($("#dcss_All_target_all").val())) - parseInt(isnull($("#dcss_All_complete_all").val())));
            }
        });

        function isnull(value) {
            if (value == "") {
                value = 0;
            }
            return (value);
        }
    });

    function dialogAjaxDone(json) {
        DWZ.ajaxDone(json);
    }

    function query1() {
        var year = $("#yearSearch",navTab.getCurrentPanel()).val();
        $("#storeRel").loadUrl("/Pages/SMD/StoreReport.aspx", { year: year },null);
    }

    function resetSummary1() {
        var year = $("#yearSearch", navTab.getCurrentPanel()).val();
        $("#storeRel").loadUrl("/Pages/SMD/StoreReport.aspx?action=reset", { year: year }, null);
    }

    function exportSummary1() {
        var year = $("#yearSearch", navTab.getCurrentPanel()).val();
        $("#StoreReportYear").val(year);
        $("#StoreReportForm").submit();
    }

    function dialogAjaxDone1(json) {
        dialogAjaxDone(json);
        query1();
    }
</script>
<div class="flowpage1" id="storeRel">
    <form id="StoreReportForm" action='/Pages/SMD/StoreReport.aspx?action=export' method='post'>
        <input type="hidden" id="StoreReportYear" name="year" >
    </form>
    <form id="formNew" runat="server" action="/Pages/SMD/StoreReport.aspx?action=save"
    method="post" onsubmit="return validateCallback(this,dialogAjaxDone1);">
    <div class="flowContent">
        <table class="formTable">
            <tr>
                <td>
                    <input type="text" id="yearSearch" runat="server" />
                    <input type="button" value="查询" onclick="query1()" />
                    <%if(HasValue) {%>
                    <input type="button" value="导出exel" onclick="exportSummary1()"/>
                    <%} %>
                </td>
            </tr>
        </table>
        <br/>
        <table class="formTable report" >
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td colspan="3">
                    年初Target
                </td>
                <td colspan="3">
                    已完成-Jul
                </td>
                <td>
                    GAP
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                    新店
                </td>
                <td>
                    翻新
                </td>
                <td>
                    Total
                </td>
                <td>
                    新店
                </td>
                <td>
                    翻新
                </td>
                <td>
                    Total
                </td>
                <td>
                    新店+翻新
                </td>
            </tr>
            <tr>
                <td rowspan="5">
                    DDCN
                </td>
                <td>
                    东部
                </td>
                <td>
                    <input id="ddcn_East_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_East_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_East_target_all" runat="server" readonly />
                </td>
                <td>
                    <input id="ddcn_East_complete" runat="server"  readonly />
                </td>
                <td>
                    <input id="ddcn_East_complete_r" runat="server" readonly />
                </td>
                <td>
                    <input  id="ddcn_East_complete_all" runat="server" readonly></input>
                </td>
                <td>
                    <input id="ddcn_East_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    南部
                </td>
                <td>
                    <input id="ddcn_South_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_South_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_South_target_all" runat="server" readonly />
                </td>
                <td>
                    <input id="ddcn_South_complete" runat="server"  readonly />
                </td>
                <td>
                    <input id="ddcn_South_complete_r" runat="server" readonly />
                </td>
                <td>
                    <input id="ddcn_South_complete_all" runat="server" readonly />
                </td>
                <td>
                    <input id="ddcn_South_gap" runat="server" readonly />
                </td>
            </tr>
            <tr>
                <td>
                    西部
                </td>
                <td>
                    <input id="ddcn_West_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_West_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_West_target_all" runat="server" readonly />
                </td>
                <td>
                    <input id="ddcn_West_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_West_complete_r" runat="server" readonly/>
                <td>
                    <input id="ddcn_West_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_West_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    北部
                </td>
                <td>
                    <input id="ddcn_North_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_North_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="ddcn_North_target_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_North_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_North_complete_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_North_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_North_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    全国
                </td>
                <td>
                    <input id="ddcn_All_target" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_target_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_target_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_complete_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="ddcn_All_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td rowspan="5">
                    DCSS
                </td>
                <td>
                    东部
                </td>
                <td>
                    <input id="dcss_East_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_East_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_East_target_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_East_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_East_complete_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_East_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_East_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    南部
                </td>
                <td>
                    <input id="dcss_South_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_South_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_South_target_all" runat="server" readonly />
                </td>
                <td>
                    <input id="dcss_South_complete" runat="server" readonly />
                </td>
                <td>
                    <input id="dcss_South_complete_r" runat="server" readonly />
                </td>
                <td>
                    <input id="dcss_South_complete_all" runat="server" readonly />
                </td>
                <td>
                    <input id="dcss_South_gap" runat="server" readonly />
                </td>
            </tr>
            <tr>
                <td>
                    西部
                </td>
                <td>
                    <input id="dcss_West_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_West_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_West_target_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_West_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_West_complete_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_West_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_West_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    北部
                </td>
                <td>
                    <input id="dcss_North_target" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_North_target_r" type="text" runat="server" />
                </td>
                <td>
                    <input id="dcss_North_target_all" runat="server" readonly />
                </td>
                <td>
                    <input id="dcss_North_complete" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_North_complete_r" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_North_complete_all" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_North_gap" runat="server" readonly/>
                </td>
            </tr>
            <tr>
                <td>
                    全国
                </td>
                <td>
                    <input id="dcss_All_target" runat="server" readonly/>
                </td>
                <td>
                    <input id="dcss_All_target_r" runat="server" readonly/> 
                </td>
                <td>
                    <input id="dcss_All_target_all" runat="server" readonly/> 
                </td>
                <td>
                    <input id="dcss_All_complete" runat="server" readonly/> 
                </td>
                <td>
                    <input id="dcss_All_complete_r" runat="server" readonly/> 
                </td>
                <td>
                    <input id="dcss_All_complete_all" runat="server" readonly/> 
                </td>
                <td>
                    <input id="dcss_All_gap" runat="server" readonly/> 
                </td>
            </tr>
        </table>
        <br/>
        <div style="text-align:right;width:99.8%">
    <input type="submit" value="保存" />
    <input type="button" value="重置" onclick="resetSummary1()"/>
    </div>
    </div>
    </form>
</div>
